home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / cli / mx2src.arc / CLI.MOD < prev    next >
Text File  |  1989-01-05  |  9KB  |  223 lines

  1.  
  2. (*              Copyright 1987 fred brooks LogicTek             *)
  3. (*                                                              *)
  4. (*                                                              *)
  5. (*   First Release                      12/8/87-FGB             *)
  6. (*                                                              *)
  7.  
  8. MODULE cli;
  9. (*$T-,$S-,$A+ *)
  10. (* IMPORT  GEMError; *)
  11. FROM SYSTEM IMPORT ADDRESS, CODE, REGISTER, SETREG;
  12. FROM GEMDOS IMPORT Super,Exec,ExecMode,OldTerm;
  13. FROM BIOS   IMPORT BConStat, BConIn, Device;
  14. FROM XBIOS  IMPORT SuperExec;
  15. FROM LOGIN  IMPORT login;
  16. VAR         cmd,dev,sr,pc,oldbios,sp,tsp,usp,newbios    :       ADDRESS;
  17.             bios [0b4H]                     :       ADDRESS;
  18.             d0,ssv,sspval                   :       ADDRESS;
  19.             i                               :       INTEGER;
  20.             active                          :       BOOLEAN;
  21.             delay,result                    :       INTEGER;
  22.  
  23. (*$P-,$S- *)
  24. PROCEDURE       multitaskbios;
  25. BEGIN
  26.         CODE(2279H,0,4a2H);     (* load saveptr *)
  27.         CODE(48e1H,1f1fH);      (* save regs *)
  28.         CODE(23c9H,0,4a2H);     (* update saveptr *)
  29.         IF active THEN
  30.            SETREG(8,oldbios);  (* move trap adr *)
  31.            CODE(43faH,22); (* lea 26(pc),a1 *)
  32.            CODE(2288H); (* move.l a0,(a1) *)
  33.            CODE(2279H,0000,04a2H); (* get saveptr *)
  34.            CODE(4cd9H,0f8f8H); (* restore regs movem *)
  35.            CODE(23c9H,0000,04a2H); (* update saveptr *)
  36.            CODE(4ef9H,0,0) (* jmp back to routine *)
  37.         END;
  38.         CODE(306fH,0);         (* move.w 0(a7),a0  get sr *)
  39.         sr:=REGISTER(8);
  40.         CODE(206fH,2);         (* move.l 2(a7),a0  get pc *)
  41.         pc:=REGISTER(8);
  42.  
  43.         IF sr<3ffH THEN        (* called from user mode *)
  44.            CODE(4e69H);        (* move.l usp,a1 *)
  45.            CODE(3069H,2);      (* move.w 2(a1),a0 *)
  46.            dev:=REGISTER(8);
  47.            CODE(4e69H);        (* move.l usp,a1 *)
  48.            CODE(3069H,0);      (* move.w 0(a1),a0 *)
  49.            cmd:=REGISTER(8);
  50.            IF (cmd=2) THEN
  51.                  active:=TRUE;
  52.                  INC(delay);
  53.                  CODE(5c8fH); (* addq.l #6,a7 correct stack *)
  54.                  sp:=REGISTER(15);
  55.                  REPEAT
  56.                     (* set user mode then back to super *)
  57.                     IF sp=sspval THEN
  58.                        tsp:=REGISTER(15);
  59.                        CODE(4e68H);     (* move.l usp,a0 *)
  60.                        usp:=REGISTER(8);
  61.                        CODE(46fcH,300H); (* move.w $300,sr *)
  62.                        FOR i:=0 TO 10 DO END; (* busy loop for mx2 *)
  63.                        CODE(42a7H);      (* clr.l  -(sp) *)
  64.                        CODE(3f3cH,20H);  (* move.w $20,-(sp) *)
  65.                        CODE(4e41H);      (* trap #1 *) 
  66.                        SETREG(15,tsp);
  67.                        SETREG(8,usp);
  68.                        CODE(4e60H);     (* move.l a0,usp *)
  69.                     END;
  70.                     CODE(48e7H,7ffeH); (* save regs *)
  71.                     CODE(9bcdH);       (* clr a5 *)
  72.                     newbios:=bios;
  73.                     bios:=oldbios;
  74.                     SETREG(0,0);
  75.                     IF BConStat(Device(dev)) THEN SETREG(0,-1) END;
  76.                     bios:=newbios;
  77.                     CODE(4cdfH,7ffeH); (* restore regs *)
  78.                     d0:=REGISTER(0);
  79.                  UNTIL d0#0;
  80.                  CODE(48e7H,7ffeH); (* save regs *)
  81.                  CODE(9bcdH);       (* clr a5 *)
  82.                  newbios:=bios;
  83.                  bios:=oldbios;
  84.                  SETREG(0,BConIn(Device(dev)));
  85.                  bios:=newbios;
  86.                  CODE(4cdfH,7ffeH); (* restore regs *)
  87.                  d0:=REGISTER(0);
  88.                  SETREG(9,pc);
  89.                  CODE(2f09H);        (* push pc to stack *)
  90.                  SETREG(9,sr);
  91.                  CODE(3f09H);        (* push sr to stack *)
  92.                  active:=FALSE; 
  93.                  SETREG(0,d0);       (* move char to d0 *)
  94.                  CODE(2279H,0000,04a2H); (* get saveptr *)
  95.                  CODE(4cd9H,0f8f8H); (* restore regs movem *)
  96.                  CODE(23c9H,0000,04a2H); (* update saveptr *)
  97.                  CODE(4e73H);        (* rte *) 
  98.            END;
  99.            IF (cmd=1) THEN
  100.                  active:=TRUE;
  101.                  INC(delay);
  102.                  CODE(5c8fH); (* addq.l #6,a7 correct stack *)
  103.                  sp:=REGISTER(15);
  104.                  CODE(48e7H,7ffeH); (* save regs *)
  105.                  CODE(9bcdH);       (* clr a5 *)
  106.                  newbios:=bios;
  107.                  bios:=oldbios;
  108.                  SETREG(0,0);
  109.                  IF BConStat(Device(dev)) THEN SETREG(0,-1) END;
  110.                  bios:=newbios;
  111.                  d0:=REGISTER(0);
  112.                  CODE(4cdfH,7ffeH); (* restore regs *)
  113.                  IF d0=0 THEN 
  114.                     (* set user mode then back to super *)
  115.                     IF sp=sspval THEN
  116.                        tsp:=REGISTER(15);
  117.                        CODE(4e68H);     (* move.l usp,a0 *)
  118.                        usp:=REGISTER(8);
  119.                        CODE(46fcH,300H); (* move.w $300,sr *)
  120.                        FOR i:=0 TO 10 DO END; (* busy loop for mx2 *)
  121.                        CODE(42a7H);      (* clr.l  -(sp) *)
  122.                        CODE(3f3cH,20H);  (* move.w $20,-(sp) *)
  123.                        CODE(4e41H);      (* trap #1 *) 
  124.                        SETREG(15,tsp);
  125.                        SETREG(8,usp);
  126.                        CODE(4e60H);     (* move.l a0,usp *)
  127.                     END;
  128.                  END;
  129.                  SETREG(9,pc);
  130.                  CODE(2f09H);        (* push pc to stack *)
  131.                  SETREG(9,sr);
  132.                  CODE(3f09H);        (* push sr to stack *)
  133.                  active:=FALSE; 
  134.                  SETREG(0,d0);       (* move char to d0 *)
  135.                  CODE(2279H,0000,04a2H); (* get saveptr *)
  136.                  CODE(4cd9H,0f8f8H); (* restore regs movem *)
  137.                  CODE(23c9H,0000,04a2H); (* update saveptr *)
  138.                  CODE(4e73H);        (* rte *) 
  139.            END;
  140.         ELSE                       (* called from super mode *)
  141.            CODE(306fH,8);  (* move.w 8(a7),a0 *)
  142.            dev:=REGISTER(8);
  143.            CODE(306fH,6);  (* move.w 6(a7),a0 *)
  144.            cmd:=REGISTER(8);
  145.            IF (cmd=2) THEN
  146.                  CODE(5c8fH); (* addq.l #6,a7 correct stack *)
  147.                  REPEAT
  148.                     CODE(48e7H,7ffeH); (* save regs *)
  149.                     CODE(9bcdH);       (* clr a5 *)
  150.                     newbios:=bios;
  151.                     bios:=oldbios;
  152.                     SETREG(0,0);
  153.                     IF BConStat(Device(dev)) THEN SETREG(0,-1) END;
  154.                     bios:=newbios;
  155.                     CODE(4cdfH,7ffeH); (* restore regs *)
  156.                     d0:=REGISTER(0);
  157.                  UNTIL d0#0;
  158.                  CODE(48e7H,7ffeH); (* save regs *)
  159.                  CODE(9bcdH);       (* clr a5 *)
  160.                  newbios:=bios;
  161.                  bios:=oldbios;
  162.                  SETREG(0,BConIn(Device(dev)));
  163.                  bios:=newbios;
  164.                  CODE(4cdfH,7ffeH); (* restore regs *)
  165.                  d0:=REGISTER(0);
  166.                  SETREG(9,pc);
  167.                  CODE(2f09H);        (* push pc to stack *)
  168.                  SETREG(9,sr);
  169.                  CODE(3f09H);        (* push sr to stack *) 
  170.                  SETREG(0,d0);       (* move char to d0 *)
  171.                  CODE(2279H,0000,04a2H); (* get saveptr *)
  172.                  CODE(4cd9H,0f8f8H); (* restore regs movem *)
  173.                  CODE(23c9H,0000,04a2H); (* update saveptr *)
  174.                  CODE(4e73H);        (* rte *) 
  175.            END;
  176.         END;
  177.  
  178.         SETREG(8,oldbios);  (* move trap adr *)
  179.         CODE(43faH,22); (* lea 26(pc),a1 *)
  180.         CODE(2288H); (* move.l a0,(a1) *)
  181.         CODE(2279H,0000,04a2H); (* get saveptr *)
  182.         CODE(4cd9H,0f8f8H); (* restore regs movem *)
  183.         CODE(23c9H,0000,04a2H); (* update saveptr *)
  184.         CODE(4ef9H,0,0) (* jmp back to routine *)
  185.  
  186. END             multitaskbios;
  187. (*$P+ *)
  188.         
  189. (*$P- *)
  190. PROCEDURE       dummyvector;
  191. BEGIN
  192.         CODE(4